package cn.hzxs.zjn.studentmanagement.dao;

import cn.hzxs.zjn.studentmanagement.domain.Score;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: Zjn ; Bring it on !!!
 * @Date: 2021/3/29 0029 12:40
 * Note:
 */
@Repository
public interface ScoreMapper {
    @Results(id = "ScoreMap", value = {
            @Result(column = "score_id", property = "SCOREID", javaType = Integer.class),
            @Result(column = "user_id", property = "USERID", javaType = Integer.class),
            @Result(column = "subject", property = "SUBJECT", javaType = String.class),
            @Result(column = "score", property = "SCORE", javaType = Integer.class),
            @Result(column = "time", property = "TIME", javaType = String.class)
    })
    @Select("select score_id,user_id,score from score where time=#{Time};")
    List<Score> getScoreByTime(String Time);

    @Select("select time,score from score where user_id=#{userId};")
    List<Map> performance(Integer userId);

    @Select("SELECT COUNT(DISTINCT user_id) FROM score; ")
    Integer countuser();

    @Select("select user_id from score")
    List<Integer> getUserId();

    @Select("select user_id,user_name,user_icon from user where user_id=#{userId}")
    Map<Object,Object> getUserInfo(Integer userId);

    @Insert("insert into score (user_id,score,time) values" +
            " (#{score.USERID},#{score.SCORE},#{score.TIME});")
    void submit(@Param("score") Score score);
}
